<?php

my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('data_setting', false);
my_component_load('jabatan_man_power', false);
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id= isset( $_GET['id'] ) ? $_GET['id']:  0;
$jt_id= isset( $_GET['jt_id'] ) ? $_GET['jt_id']:  0;
$facebox=true ; 
$modulname = "Admin _BN_ Konfigurasi Data _BN_ Kebutuhan pemegang jabatan" ;
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){ 
		case   "page" :
			$validatepost = form_jabatan_man_power_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_jabatan_man_power_create($id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_jabatan_man_power_submit($id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			break;	
		case   "jabatan_terkait_page" :
			$validatepost = form_jabatan_terkait_validate($id,$jt_id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_jabatan_terkait_create($id,$jt_id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_jabatan_terkait_submit($id,$jt_id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			break;				
	}
else: 
	if($task == 'page'){
		$content  = form_jabatan_man_power_create($id);
		generate_my_web($content,"","plain.php");
		exit; 	
	}elseif($task =='edit'){
		$pagename= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		if($facebox){
			facebox_page('index.php?com=jabatan_man_power&task=page&id='.$id , $pagename , 350	); 			
		}else{				
			$content  = form_jabatan_man_power_create($id);
			generate_my_web($content, $pagename  );	
		}
	}elseif($task =='list_jabatan_terkait'){
		$pagename = $modulname;
		$pagename .= " _BN_ Jabatan Terkait";
		load_facebox_script();
		$view =  list_jabatan_terkait($id);
		generate_my_web($view, $pagename );	
	}elseif($task =='jabatan_terkait_create'){
		$title= "Jabatan terkait";
		facebox_page('index.php?com=jabatan_man_power&task=jabatan_terkait_page&id='.$id.'&jt_id='.$jt_id, $title , 180	); 
	}elseif($task == 'jabatan_terkait_page'){
		$content  = form_jabatan_terkait_create($id,$jt_id);
		generate_my_web($content,"Jabatan Terkait","plain.php");
		exit; 	
	}elseif($task == "jabatan_terkait_delete"){ 
		delete_jabatan_terkait($id);
		my_direct($_SERVER['HTTP_REFERER']);		
	}else{
		$href =null;
		$pagename = "Man Power";
		load_facebox_script();	
		$view = list_jabatan_man_power();
		$content = spliter_browser( $view , $pagename ,$href);
		generate_my_web($content, $modulname ); 
	}
endif;  

?>